 var infowindow;
 var map;
 
 var baseURL ="https://labs.commutegreenerinfo.com/it/";

  function initializeStartMap() {
	  
//    var myLatlng = new google.maps.LatLng(57.70779280783442, 11.937975883483887);
//    var myOptions = {
//      zoom: 10,
//      center: myLatlng,
//      mapTypeId: google.maps.MapTypeId.ROADMAP
//    }
    
	 
    var myOptions1 = {
			center : new google.maps.LatLng(57.70779280783442, 11.937975883483887),
			zoom : 10,
			mapTypeId : google.maps.MapTypeId.ROADMAP
		};
		//gothenburg center
		var myOptions2 = {
			center : new google.maps.LatLng(19.429413676234212, -99.12683863302618),
			zoom : 10,
			mapTypeId : google.maps.MapTypeId.ROADMAP
		};
		
	
		
		 if(document.getElementById("citymap1").value == "mexico"){
			 map = new google.maps.Map(document.getElementById("map_canvasCompared"), myOptions2);
				
		  }else if(document.getElementById("citymap1").value == "gothenborg"){
			  map = new google.maps.Map(document.getElementById("map_canvasCompared"), myOptions1);
			  
		  }
    
   
//    map = new google.maps.Map(document.getElementById("map_canvasCompared"), myOptions);
    downloadUrl("js/compareLocation.xml", function(data) {
    	//"js/moredata.xml"  "js/Location.xml"  C:/files/Location.xml
      var markers = data.documentElement.getElementsByTagName("marker");
      for (var i = 0; i < markers.length; i++) {
        var latlng = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
        var marker = createMarker(markers[i].getAttribute("name"), latlng);
       }
     });
   
   
  }
  
//Ns code  
  
  
//  function createMarker(name, latlng) {
//	    var marker = new google.maps.Marker({position: latlng, map: map});
//	    google.maps.event.addListener(marker, "click", function() {
//	      if (infowindow) infowindow.close();
//	      infowindow = new google.maps.InfoWindow({content: name});
//	      infowindow.open(map, marker);
//	    });
//	    
//	    if(name =="BUS"){
//	    	iconFile = 'images/black.png'; 
//	    }
//	    else if(name =="CAR"){
//	    	iconFile = 'images/red.png'; 
//	    }
//	    else if(name =="BICYCLE"){
//	    	iconFile = 'images/green.png'; 
//	    }
//	    else if(name =="WALKING"){
//	    	iconFile = 'images/yellow.png'; 
//	    }
//	    else if(name =="FERRY"){
//	    	iconFile = 'images/blue.png'; 
//	    }
//	    else if(name =="TRAIN_SUBWAY_METRO"){
//	    	iconFile = 'images/pink.png'; 
//	    }
//	    else if(name =="AEROPLANE"){
//	    	iconFile = 'images/silver.png'; 
//	    }
//	    else if(name =="DESTINATION"){
//	    	iconFile = 'images/check_flag.png'; 
//	    }
//	    
//	    marker.setIcon(iconFile) ;
//	    return marker;
//	  }
  

  
  function createMarker(name, latlng) {

		var iconFile;
		if (name == "BUS") {
			iconFile = "images/black.png";
		} else if (name == "CAR") {
			iconFile = 'images/red.png';
		} else if (name == "BICYCLE") {
			iconFile = 'images/green.png';
		} else if (name == "WALKING") {
			iconFile = 'images/purple.png';
		} else if (name == "FERRY") {
			iconFile = 'images/blue.png';
		} else if (name == "TRAIN_SUBWAY_METRO") {
			iconFile = 'images/pink.png';
		} else if (name == "AEROPLANE") {
			iconFile = 'images/silver.png';
		}
	    else if(name =="DESTINATION"){
	    	iconFile = 'images/check_flag.png'; 
	    }
	  	
	  	var marker = new google.maps.Marker({
	  		position : latlng,
	  		map : map,
	  		icon : baseURL+iconFile
	  	});

//	  	google.maps.event.addListener(marker, "click", function() {
//	  		if (infowindow1)
//	  			infowindow.close();
//	  		infowindow1 = new google.maps.InfoWindow({
//	  			content : name
//	  		});
//	  		infowindow1.open(map1, marker);
//	  	});
	  	
	  	 google.maps.event.addListener(marker, "click", function() {
		      if (infowindow) infowindow.close();
		      infowindow = new google.maps.InfoWindow({content: name});
		      infowindow.open(map, marker);
		    });
	  	
	  	
	  }
 